<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>地铁图展示</title>
<script type="text/javascript" src="https://api.map.baidu.com/api?type=subway&v=1.0&ak=TdG3lrRScvWOZDTj80RytM1qhz8wWo1f"></script>
<style type="text/css">
    #container{height:100%}
</style>
</head>
<body>
<div id="container"></div>
<script type="text/javascript">
   
     var subwayCityName = '上海';
    var list = BMapSub.SubwayCitiesList;
    var subwaycity = null;
    for (var i = 0; i < list.length; i++) {
        if (list[i].name === subwayCityName) {
            subwaycity = list[i];
            break;
        }
    }
    var subway = new BMapSub.Subway('container', subwaycity.citycode);
    var zoomControl  = new BMapSub.ZoomControl({
        anchor: BMAPSUB_ANCHOR_BOTTOM_RIGHT,
        offset: new BMapSub.Size(10,100)
    });
    subway.addControl(zoomControl);
    subway.openInfoWindow(infowindow, '诸光路');
    subway.setCenter('诸光路');
    subway.setZoom(1);
    subway.addEventListener('subwayloaded', function() {
        var drct = new BMapSub.Direction(subway);
        drct.search('诸光路', '伊犁路');
    });
    subway.addEventListener('directioncomplete', function() {
        alert('可以自定义点击详情后的操作！');
    });
</script>
</body>
</html>